<script src="http://code.jquery.com/jquery-1.5.js"></script>
<?php use_helper('DateForm') ?>
<?php if(!empty($arCalendar)):?>
<div id="calendar">
    <div class="calendar_top">
        <div class="calendar_arrow">
           <?php echo link_to('<<'
           					, '#'
           					, array('onclick' => "jQuery.ajax({ url: 'calendar?id=" . $prevDate . "' })
														    .success(function(data) { jQuery('#calendar').html(data) })
														    .error(function() { alert('error'); })
														    ;"));?>
        </div>
        <div class="calendar_month">
           <?php echo link_to(date('Y', $tm) . '&nbsp;' . $month
                           , 'calendar/eventsmonth?id=' . $tm);?> 
        </div>
        <div class="calendar_arrow">
           <?php echo link_to('>>'
           					, '#'
           					, array('onclick' => "jQuery.ajax({ url: 'calendar?id=" . $nextDate . "' })
														    .success(function(data) { jQuery('#calendar').html(data) })
														    .error(function() { alert('error'); })
														    ;"));?>
        </div>
    </div>
    <div class="calendar_body">
        <?php for( $i = 0; $i < count($arCalendar); $i++ ): ?>
            <div class="calendar_day">
            <?php if( $arCalendar[$i]->EntriesQnt > 0 ): ?>
                <?php echo link_to(($arCalendar[$i]->Day ? $arCalendar[$i]->Day : ' ') . '<div class="link_hover">'. $arCalendar[$i]->Title . '</div>'
                				, 'calendar/events?id=' . date('Y-n-', $tm) . $arCalendar[$i]->Day
                				, array('style' => 'color:red;')) ?>
                <?php else: ?>
                    <?php echo $arCalendar[$i]->Day ? $arCalendar[$i]->Day : ' '?>
                <?php endif; ?>
            </div>
        <?php endfor; ?>
    </div>
<?php endif; ?>
<?php 

//$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
//$input = '<a href="http://www.ratlita.eu" target="_blank"><?php echo $val[]</a>';
//preg_match_all("/$regexp/siU", $input, $matches);
//debugvar($matches, '$matches');
//echo '<a href="http://' . $matches . '" target="_blank">tratata</a>';

?>
</div>
